<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">

	function checkAll(allNode){
		//找到所有的的选项
		var items = document.getElementsByName("item");
		//找到全选按钮的对象
		//var allNode = document.getElementsByName("all")[0];
		for(var i = 0 ; i<items.length ; i++){
			items[i].checked = 	allNode.checked;
		}
	}
	
	
	function getSum(){
		var items = document.getElementsByName("item");
		var sum = 0;
		for(var i = 0 ; i<items.length ; i++){
			if(items[i].checked){
				sum += parseInt(items[i].value);
			}	
		}	
		var spanNode = document.getElementById("sumid");
		spanNode.innerHTML = ("&nbsp;&nbsp;&nbsp;&yen;"+sum).fontcolor("green");
	}
	


</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
	<div>商品列表</div>
        <input type="checkbox" name="item" value="3000" />笔记本电脑3000元<br />
        <input type="checkbox" name="item" value="1800"  />笔记本电脑1800元<br />
        <input type="checkbox" name="item" value="300"  />笔记本电脑300元<br />
        <input type="checkbox" name="item" value="3000"  />笔记本电脑3000元<br />
        <input type="checkbox" name="item" value="3000"  />笔记本电脑3000元<br />
        <input type="checkbox" name="item" value="3000"  />笔记本电脑3000元<br />
        <input type="checkbox" name="all" onclick="checkAll(this)"  /> 全选<br />
        <input type="button" value="总金额：" onclick="getSum()" /><span id="sumid"></span>
</body>
</html>
